package interceptor;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

import config.Constant;

@SuppressWarnings("serial")
public class AuthInterceptor extends MethodFilterInterceptor {

	@Override
	protected String doIntercept(ActionInvocation arg0) throws Exception {
		
		ActionContext actionContext = arg0.getInvocationContext();
		if (actionContext.getSession().get(Constant.LOGININFO) == null){
			ServletActionContext.getResponse().sendRedirect(Constant.LOGIN_URL);
			return Action.NONE;
		}
		
		return arg0.invoke();
	}
}
